<?php 

//初始化,xml数据提取转存进数组
function Initialize($xmlstring) {
	
	$Rex->Pattern="<start>([^<]*)<\\/start>.*?<end>([^<]*)<\\/end>(?:<realm>[^<]*<\\/realm>)?(?:<zone>([^<]*)<\\/zone>)?"; //取得起始,结束时间和 地区名(如果有)
	$Rex2->Pattern="<note>([^<]*?)<\\/note><joins>"; //取得备注(如果有)


	if ($Rex->test($xmlRaidTrack)) {
		$Matches1=$Rex->Execute;
		$timeStart=cov2Time($Matches1[0]->$SubMatches[0]);
		$timeEnd=cov2Time($Matches1[0]->$SubMatches[1]);
		$strRaidTitle=$Matches1[0]->$SubMatches[2];
		if ($Rex2->test($xmlRaidTrack)) {
			$Matches2=$Rex2->Execute;
			$strRaidnote=$Matches2[0]->$SubMatches[0];
		} 
		//Response.write timeStart&" , "&timeEnd&" , "&strRaidTitle&" , "&strRaidnote&" ,<br>"
	}else{
		$errtext=$errtext."缺少必要的基本信息<br>";
	} 


	//取得player数组
	print "<br><br>player<br>";
	$Rex->Pattern="<playerinfos>(.*)<\\/playerinfos>";
	$Rex2->Pattern="(?:<player>|<key\\d{1,4}>)(.*?)(?:<\\/player>|<\\/key\\d{1,4}>)";
	//Rex2.Pattern = "(?:<player>|<key\\d{1,4}>)<name>([^<]*)<\\/name><race>([^<]*)<\\/race>(?:<guild>([^<]*)<\\/guild>)?<sex>([^<]*)<\\/sex><class>([^<]*)<\\/class>(?:<note><!\\[CDATA\\[(.*?)\\]\\]><\\/note>)?<level>(\\d{1,2})<\\/level>(?:<\\/player>|<\\/key\\d{1,4}>)"
	if ($Rex->test($xmlRaidTrack) && $Rex2->test($xmlRaidTrack)) {
		$Matches1=$Rex->Execute;
		$Matches2=$Rex2->Execute;
		$index=0;

		foreach ($Matches2 as $Match){
			$Rex3->Pattern="<name>([^<]*)<\\/name>";
			$Matches3=$Rex3->Execute;
			$ArrPlayer[$index][0]=$Matches3[0]->$SubMatches[0]; //name

			$Rex3->Pattern="<race>([^<]*)<\\/race>";
			$Matches3=$Rex3->Execute;
			if ($Rex3->test($Match->SubMatches(0))){
				$ArrPlayer[$index][1]=$Matches3[0]->$SubMatches[0]; //种族
			} 

			$Rex3->Pattern="<guild>([^<]*)<\\/guild>";
			$Matches3=$Rex3->Execute;
			if ($Rex3->test($Match->SubMatches(0))){
				$ArrPlayer[$index][2]=$Matches3[0]->$SubMatches[0]; //公会
			} 

			$Rex3->Pattern="<sex>([^<]*)<\\/sex>";
			$Matches3=$Rex3->Execute;
			if ($Rex3->test($Match->SubMatches(0))){
				$ArrPlayer[$index][3]=$Matches3[0]->$SubMatches[0]; //性别
			} 

			$Rex3->Pattern="<class>([^<]*)<\\/class>";
			$Matches3=$Rex3->Execute;
			if ($Rex3->test($Match->SubMatches(0))){
				$ArrPlayer[$index][4]=$Matches3[0]->$SubMatches[0]; //职业
			} 

			$Rex3->Pattern="<note>(.*?)<\\/note>";
			$Matches3=$Rex3->Execute;
			if ($Rex3->test($Match->SubMatches(0))){
				$ArrPlayer[$index][5]=$Matches3[0]->$SubMatches[0]; //注释
			} 

			$Rex3->Pattern="<level>(\\d{1,2})<\\/level>";
			$Matches3=$Rex3->Execute;
			if ($Rex3->test($Match->SubMatches(0))){
				$ArrPlayer[$index][6]=$Matches3[0]->$SubMatches[0]; //等级
			} 
			//Response.write Match.SubMatches.count&ArrPlayer(index,0)&ArrPlayer(index,1)&ArrPlayer(index,2)&ArrPlayer(index,3)&ArrPlayer(index,4)&ArrPlayer(index,5)&ArrPlayer(index,6)&" ("&index&"<br>"
			$index=$index+1;
		}//foreach

	}else{
		$errtext=$errtext."未找到玩家数据<br>";
	} 


	//取得join数组
	print "<br><br>join<br>";
	$Rex->Pattern="<joins>(.*)<\\/joins>";
	$Rex2->Pattern="(?:<join>|<key\\d{1,4}>)<player>([^<]*)<\\/player>.*?<time>([^<]*)<\\/time>(?:<\\/join>|<\\/key\\d{1,4}>)";
	if ($Rex->test($xmlRaidTrack) && $Rex2->test($xmlRaidTrack)){
		$Matches1=$Rex->Execute;
		$Matches2=$Rex2->Execute;
		$index=0;
		foreach ($Matches2 as $Match) {
			$ArrJoin[$index][0]=$match->SubMatches(0);
			$ArrJoin[$index][1]=cov2time($match->SubMatches(1));
			//Response.write Match.SubMatches.count&ArrJoin(index,0)&ArrJoin(index,1)&"<br>"
			$index=$index+1;
		}
	}else{
		print "无成员中途加入<br>";
	} 


	//取得leave数组
	print "<br><br>leave<br>";
	$Rex->Pattern="<leaves>(.*)<\\/leaves>";
	$Rex2->Pattern="(?:<leave>|<key\\d{1,4}>)<player>([^<]*)<\\/player><time>([^<]*)<\\/time>(?:<\\/leave>|<\\/key\\d{1,4}>)";
	if ($Rex->test($xmlRaidTrack) && $Rex2->test($xmlRaidTrack)){
		$Matches1=$Rex->Execute;
		$Matches2=$Rex2->Execute;
		$index=0;
		foreach ($Matches2 as $Match){
			$ArrLeave[$index][0]=$match->SubMatches(0);
			$ArrLeave[$index][1]=cov2Time($match->SubMatches(1));
			//Response.write Match.SubMatches.count&ArrLeave(index,0)&ArrLeave(index,1)&"<br>"
			$index=$index+1;
		}
	}else{
		print "无成员中途离开<br>";
	} 


	//取得bosskills数组
	print "<br><br>bosskills<br>";
	$Rex->Pattern="<bosskills>(.*)<\\/bosskills>";
	$Rex2->Pattern="(?:<bosskill>|<key\\d{1,4}>)(.*?)(?:<attendees>.*?<\\/attendees>)?(?:<\\/bosskill>|<\\/key\\d{1,4}>)";
	//			Rex2.Pattern = "<bosskill><name>([^<]*)<\\/name><time>([^<]*)<\\/time><\\/bosskill>"
	if ($Rex->test($xmlRaidTrack) && $Rex2->test($xmlRaidTrack)){

	$Matches1=$Rex->Execute;
	$Matches2=$Rex2->Execute;
		$index=0;
		foreach ($Matches2 as $Match){
			$Rex3->Pattern="<name>([^<]*)<\\/name>";
			$Matches3=$Rex3->Execute;
			$ArrBosskill[$index][0]=$Matches3[0]->$SubMatches[0]; //首领名

			$Rex3->Pattern="<time>([^<]*)<\\/time>";
			$Matches3=$Rex3->Execute;
			$ArrBosskill[$index][1]=cov2Time($Matches3[0]->$SubMatches[0]); //发生事件

			print $ArrBosskill[$index][0].$ArrBosskill[$index][1]."<br>";
			$index=$index+1;
		}
	}else{
		print "未找到首领击杀事件<br>";
	} 


	//取得loot数组
	print "<br><br>loot<br>";
	$Rex->Pattern="<loots>(.*)<\\/loots>";
	$Rex2->Pattern="(?:<loot>|<key\\d{1,4}>)(.*?)(?:<\\/loot>|<\\/key\\d{1,4}>)";
	//Rex2.Pattern = "(?:<loot>|<key\\d{1,4}>)<itemname>([^<]*)<\\/itemname><itemid>(\\d{4,6})[^<]*<\\/itemid>(?:<icon>([^<]*)<\\/icon>)?.*?(?:<color>([^<]*)<\\/color>|)<count>(\\d)<\\/count><player>([^<]*)<\\/player>(?:<costs>([^<]*)<\\/costs>)?<time>([^<]*)<\\/time><zone>([^<]*)<\\/zone><boss>([^<]*)</boss>(?:<tooltip>([^<]*)<\\/tooltip>)?<note>(-?[^-<]*)?(?: - Zone:.*? - Boss:[^\\]]*?)?<\\/note>(?:<\\/loot>|<\\/key\\d{1,4}>)"
	if ($Rex->test($xmlRaidTrack) && $Rex2->test($xmlRaidTrack)){

		$Matches1=$Rex->Execute;
		$Matches2=$Rex2->Execute;

		$index=0;
		foreach ($Matches2 as $Match) {
			$Rex3->Pattern="<itemname>([^<]*)<\\/itemname>";
			$Matches3=$Rex3->Execute;
			$ArrLoot[$index][0]=$Matches3[0]->$SubMatches[0]; //物品名

			$Rex3->Pattern="<itemid>(\\d{4,6})[^<]*<\\/itemid>";
			$Matches3=$Rex3->Execute;
			if ($Rex3->test($Match->SubMatches(0))){
				$ArrLoot[$index][1]=$Matches3[0]->$SubMatches[0]; //int物品ID
			} 

			$Rex3->Pattern="<icon>([^<]*)<\\/icon>";
			$Matches3=$Rex3->Execute;
			if ($Rex3->test($Match->SubMatches(0))){
				$ArrLoot[$index][2]=$Matches3[0]->$SubMatches[0]; //icon
			} 

			$Rex3->Pattern="<color>([^<]*)<\\/color>";
			$Matches3=$Rex3->Execute;
			if ($Rex3->test($Match->SubMatches(0))){
				$ArrLoot[$index][3]=$Matches3[0]->$SubMatches[0]; //color
			} 

			$Rex3->Pattern="<count>(\\d)<\\/count>";
			$Matches3=$Rex3->Execute;
			if ($Rex3->test($Match->SubMatches(0))){
				$ArrLoot[$index][4]=$Matches3[0]->$SubMatches[0]; //int数量
			} 

			$Rex3->Pattern="<player>(.*?)<\\/player>";
			$Matches3=$Rex3->Execute;          $Match->SubMatches(0));
			if ($Rex3->test($Match->SubMatches(0))){
				$ArrLoot[$index][5]=$Matches3[0]->$SubMatches[0]; //获得者
			} 

			$Rex3->Pattern="<costs>(.*?)<\\/costs>";
			$Matches3=$Rex3->Execute;          $Match->SubMatches(0));
			if ($Rex3->test($Match->SubMatches(0))){
				$ArrLoot[$index][6]=$Matches3[0]->$SubMatches[0]; //DKPcosts
			} 

			$Rex3->Pattern="<time>(.*?)<\\/time>";
			$Matches3=$Rex3->Execute;          $Match->SubMatches(0));
			if ($Rex3->test($Match->SubMatches(0))){
				$ArrLoot[$index][7]=cov2Time($Matches3[0]->$SubMatches[0]); //时间
			} 

			$Rex3->Pattern="<zone>(.*?)<\\/zone>";
			$Matches3=$Rex3->Execute;          $Match->SubMatches(0));
			if ($Rex3->test($Match->SubMatches(0))){
				$ArrLoot[$index][8]=$Matches3[0]->$SubMatches[0]; //地区
			} 

			$Rex3->Pattern="<boss>(.*?)<\\/boss>";
			$Matches3=$Rex3->Execute;          $Match->SubMatches(0));
			if ($Rex3->test($Match->SubMatches(0))){
				$ArrLoot[$index][9]=$Matches3[0]->$SubMatches[0]; //掉落者
			} 

			$Rex3->Pattern="<tooltip>(.*?)<\\/tooltip>";
			$Matches3=$Rex3->Execute;          $Match->SubMatches(0));
			if ($Rex3->test($Match->SubMatches(0))){
				$ArrLoot[$index][10]=$Matches3[0]->$SubMatches[0]; //tooltip
			} 

			$Rex3->Pattern="<note>(-?[^-<]*)?(?: - Zone:.*? - Boss:[^\\]]*?)?<\\/note>";
			$Matches3=$Rex3->Execute;          $Match->SubMatches(0));
			if ($Rex3->test($Match->SubMatches(0))){
				$ArrLoot[$index][11]=$Matches3[0]->$SubMatches[0]; //备注/DKP
			} 

		//Response.write Match.SubMatches.count&ArrPlayer(index,0)&ArrPlayer(index,1)&ArrPlayer(index,2)&ArrPlayer(index,3)&ArrPlayer(index,4)&ArrPlayer(index,5)&ArrPlayer(index,6)&" ("&index&"<br>"
			$index=$index+1;
		}

	}else{
		print "未找到物品拾取事件<br>";
	} 

	return $function_ret;
} //Initialize() End.






//创建/更新活动记录,获得RaidID,清空事件
function RaidCreative($timeStart,$timeEnd,$strRaidTitle,$strRaidnote) {
	$sql="select * from raid where raid_concentratetime=#".$timeStart."#";
	$result = mysql_query($sql);$sql      $conn
	if ($result->eof || $result->bof) {
		$result->close;
		$sql="select * from raid where (id is null)";
		$result = mysql_query($sql);$sql        $conn
		$result->addnew;
		$result["raid_name"]=$strRaidTitle.$strRaidnote;
		if ($strRaidTitle.$strRaidnote==""){
			$result["raid_name"]="未命名的活动";
		} 
		$result["raid_concentratetime"]=$timeStart;
		$result["raid_actiontime"]=$timeStart;
		$result["raid_endtime"]=$timeEnd;
		$result["raid_personnel"]=40;
		$result["raid_player"]="";
		$result["raid_commander"]=${"raid_commander"};
		$result["raid_plan"]=htmlencode2(${"raid_plan"});
		if ($result["raid_step"]==0){
			$result["raid_step"]=1;
			$result["raid_ruler"]=1;
			$result["raid_ruler"]="";
		} 

		if (${"class_name"}!=""){
			$result["raid_class"]=${"class_name"};
		} 
		if (${"ruler_name"}!=""){
			$result["raid_ruler"]=${"ruler_name"};
		} 
		$result->update;
		//	response.write "添加新记录"
	}else{
		$result["raid_name"]=$strRaidTitle.$strRaidnote;
		if ($strRaidTitle.$strRaidnote=="" && $result["raid_name"]==""){
			$result["raid_name"]="未命名的活动";
		} 
		$result["raid_concentratetime"]=$timeStart;
		$result["raid_actiontime"]=$timeStart;
		$result["raid_endtime"]=$timeEnd;
		if ($result["raid_step"]==0){
			$result["raid_step"]=1;
		} 

		$result["raid_ruler"]=1;
		if (${"class_name"}!=""){
			$result["raid_class"]=${"class_name"};
		} 
		if (${"ruler_name"}!=""){
			$result["raid_ruler"]=${"ruler_name"};
		} 
		$result->update;
		//	response.write "修改存在记录"
	} 

	$result->close;
	$RaidID=getRaidID($timeStart);
	//删除此Raid全部事件
	$conn->execute("Delete * from raid_event where event_raidid=".$RaidID);
	return $function_ret;
} 





//成员创建/更新
function dbRenewPlayers($arrPlayer){
	$strPlayerList=",";
	for ($pindex=0; $pindex<=count($arrPlayer)-1; $pindex=$pindex+1){
		$strPlayerList=$strPlayerList.$arrPlayer[$pindex][0].",";
		$sql="select * from player where player_name='".$arrPlayer[$pindex][0]."'";
		$result = mysql_query($sql);$sql        $conn
		if ($result->eof || $result->bof){
			$result->close;
			$sql="select * from player where (id is null)";
			$result = mysql_query($sql);$sql          $conn
			$result->addnew;
			$result["player_name"]=$arrPlayer[$pindex][0];
			$result["player_level"]=$arrPlayer[$pindex][6];
			$result["player_race"]=getFormatRaceName($arrPlayer[$pindex][1]);
			$result["player_class"]=getFormatProfessionName($arrPlayer[$pindex][4]);
			//rs("player_guildlevel")=strGuildRank
			//rs("player_honor")="无"
			$result["player_jointime"]=$timestart;
			$result["player_BaseDKP"]=0;
			$result["player_DKP"]=0;
			$result["player_skill_1"]="未知";
			$result["player_skill_2"]="未知";
			$result["player_looted"]="";
			$result->update;
		}else{
			if ($result["player_level"]!=$strLevel || $result["player_race"]!=getFormatRaceName($strRace) || $result["player_class"]!=getFormatProfessionName($strClass)){
				$result["player_name"]=$arrPlayer[$pindex][0];
				$result["player_race"]=getFormatRaceName($arrPlayer[$pindex][1]);
				if ($strGuildRank!=""){
					$result["player_guildlevel"]=$strGuildRank;
				} 
				$result["player_class"]=getFormatProfessionName($arrPlayer[$pindex][4]);
				$result->update;
			} elseif ($result["player_guildlevel"]!=$strGuildRank && $strGuildRank!="") {
				$result["player_guildlevel"]=$strGuildRank;
				$result->update;
			} 
		} 
		$result->close;
	} //for END.
	return $function_ret;
} 



//在Raid中写入参与人员ID
function dbAddRaidPlayer($strPlayerList){
	$sql="select * from raid where id=".$RaidID;
	$result2->open$sql      $conn
	$result2["raid_player"]=getPlayerIDs($strPlayerList);
	$result2->update;
	$result2->close;
	return $function_ret;
} 

//加入事件处理
function processJoinEvents($ArrJoin){
	if (!is_array($Arrjoin)){
		return $function_ret;
	} 
	print "处理成员加入事件...<br>";
	$Sql="Select * from raid_event where (id is null)";
	$result2->open$sql      $conn
	for ($Jindex=0; $Jindex<=count($ArrJoin)-1; $Jindex=$Jindex+1){
		if ($ArrJoin[$Jindex][0]!=""){
			if ($DateDiff["n"][$ArrJoin[$Jindex][1]][$timeStart]<0){
				$result2->addnew;
				$result2["event_raidid"]=$RaidID;
				$result2["event_time"]=$ArrJoin[$Jindex][1];
				$result2["event_class"]="加入";
				$result2["event_dkp"]=0;
				$result2["event_object"]=name2idS($ArrJoin[$Jindex][0]);
				$result2["event_object2"]="";
				$result2->update;
			} 
		} 
	}//for END.
	$result2->close;
	print "完成<br>";
	return $function_ret;
} 

//离开相关处理
function processLeaveEvents($ArrLeave){
	if (!is_array($ArrLeave)){
		return $function_ret;
	} 
	print "处理成员离开事件...<br>";
	$Sql="Select * from raid_event where (id is null)";
	$result2->open$sql      $conn
	for ($Lindex=0; $Lindex<=count($ArrLeave)-1; $Lindex=$Lindex+1){
		if ($ArrLeave[$Lindex][0]!=""){
			if ($DateDiff["n"][$ArrLeave[$Lindex][1]][$timeEnd]>5){
				$result2->addnew;
				$result2["event_raidid"]=$RaidID;
				$result2["event_time"]=$ArrLeave[$Lindex][1];
				$result2["event_class"]="离开";
				$result2["event_dkp"]=0;
				$result2["event_object"]=name2idS($ArrLeave[$Lindex][0]);
				$result2["event_object2"]="";
				$result2->update;
			} 
		} 
	}//for END.
	$result2->close;
	print "完成<br>";
	return $function_ret;
} 

//首领击杀事件处理
function processBosskillsEvents($ArrBosskill){
	if (!is_array($ArrBosskill)){
		return $function_ret;
	} 
	print "处理首领击杀事件...";
	$Sql="Select * from raid_event where (id is null)";
	$result = mysql_query($sql);$sql      $conn
	for ($kindex=0; $kindex<=count($ArrBosskill)-1; $kindex=$kindex+1){
		$result->addnew;
		$result["event_raidid"]=$RaidID;
		$result["event_time"]=$ArrBosskill[$kindex][1];
		$result["event_class"]="击杀";
		$result["event_dkp"]="0";
		$result["event_object"]="-";
		$result["event_object2"]=$ArrBosskill[$kindex][0];
		$result->update;
	}
	$result->close;
	print "完成<br>";
	return $function_ret;
} 

//物品相关处理|||
function processLootEvents($ArrLoot) {
	if (!is_array($ArrLoot)){
		return $function_ret;
	} 
	print "处理物品拾取事件...<br>";
	$Sql="Select * from raid_event where (id is null)";
	$result = mysql_query($sql);$sql      $conn
	for ($Lindex=0; $Lindex<=count($ArrLoot)-1; $Lindex=$Lindex+1){
		$itemName=$ArrLoot[$Lindex][0];
		$itemID=$ArrLoot[$Lindex][1];
		$itemIcon=$ArrLoot[$Lindex][2];
		$itemColor=$ArrLoot[$Lindex][3];
		$itemCount=$ArrLoot[$Lindex][4];
		$itemLooter=$ArrLoot[$Lindex][5];
		$itemCosts=$ArrLoot[$Lindex][6];
		if ($ArrLoot[$Lindex][6]=="" || !is_numeric($ArrLoot[$Lindex][6])){
			$itemCosts=0;
		} 
		$itemLootTime=$ArrLoot[$Lindex][7];
		$itemZone=$ArrLoot[$Lindex][8];
		$itemWreck=$ArrLoot[$Lindex][9];
		$itemTooltip=$ArrLoot[$Lindex][10];
		$itemNote=$ArrLoot[$Lindex][11];
		$itemPay="";
		if ($itemNote!=""){
			if ((strpos($itemNote,"/") ? strpos($itemNote,"/")+1 : 0)){
				$itemPay=substr($itemNote,strlen($itemNote)-(strlen($itemNote)-(strpos($itemNote,"/") ? strpos($itemNote,"/")+1 : 0)));
				$itemCosts=substr($itemNote,0,(strpos($itemNote,"/") ? strpos($itemNote,"/")+1 : 0)-1);
			}else{
				$itemCosts=$itemNote;
			} 
		} 

		if ($itemTooltip!=""){
			$itemTooltip=$itemColor.";".$itemIcon.";".$itemTooltip;
		} 



		//Response.write itemName&" "&itemCosts&" {"&itemPay&"}<br>"
		for ($ci=1; $ci<=intval($itemCount); $ci=$ci+1){
			if (is_numeric($itemCosts)){
				dbADDRaidLoot("拾取",$itemCosts,$itemPay,name2idS($itemLooter),$itemName."#".$itemID,$itemLootTime,$itemTooltip);
			}elseif (strtoupper($itemNote)=="BOE"){
				dbADDRaidLoot("仓库",$intBankItemCost,$itemNote,name2idS($itemLooter),$itemName."#".$itemID,$itemLootTime,$itemTooltip);
			}elseif (strtoupper($itemNote)=="ENC"){
				dbADDRaidLoot("分解",0,0,name2idS($itemLooter),$itemName."#".$itemID,$itemLootTime,$itemTooltip);
			} 
		}

	} //for END.

	$result->close;
	print "完成<br>";
	return $function_ret;
} 

//获得db的指定活动开始时间的条目ID
function getRaidID($t){
	$sql="select id from raid where raid_concentratetime=#".$t."#";
	$result = mysql_query($sql);$sql      $conn
	$function_ret=$result["id"];
	$result->close;
	return $function_ret;
} 

//获得一组角色名字的ID数组
function getPlayerIDs($strPlayerList){
	$strPlayerList=explode(",",substr(substr($strPlayerList,0,strlen($strPlayerList)-1),1));
	$sql="select * from player";
	$result3->open$sql      $conn
	for ($i=1; $i<=$result3->recordcount; $i=$i+1){
		for ($j=0; $j<=count($strPlayerList); $j=$j+1){
			if ($result3["player_name"]==$strPlayerList[$j]){
				$arrPlayerListNum[$j]=$result3["id"];
			} 
		}
		$result3->movenext;
	}
	$result3->close;
	$function_ret=$join[$arrPlayerListNum][", "];
	return $function_ret;
} 

//数据写入物品拾取事件
function Private(){
	dbADDRaidLoot($strclass,$cost1,$cost2,$O1,$O2,$itemLootTime,$strtooltip);
	$result->addnew;
	$result["event_raidid"]=$RaidID;
	$result["event_time"]=$itemLootTime;
	$result["event_class"]=$strclass;
	$result["event_dkp"]=$cost1;
	$result["event_object"]=$O1;
	$result["event_object2"]=$O2;
	$result["event_object2_tooltip"]="";
	if ($cost2!=""){
		$result["event_dkp2"]=$cost2;
	} 
	if ($strtooltip!=""){
		$result["event_object2_tooltip"]=$strtooltip;
	} 
	$result->update;
	return $function_ret;
} 

//滤掉多余的加入离开事件(由插件重复记录引起)
function fixEvents($events){
	if (!is_array($events)){
		return $function_ret;
	} 
	for ($eventindex=0; $eventindex<=count($events)-1; $eventindex=$eventindex+1){
		if ($events[$eventindex][0]!=""){
			for ($subindex=$eventindex+1; $subindex<=count($events)-1; $subindex=$subindex+1){
				if ($events[$subindex][0]!=""){
					if ($events[$eventindex][0]==$events[$subindex][0] && $DateDiff["n"][$events[$eventindex][1]][$events[$subindex][1]]<5){
						$events[$subindex][0]="";
						$events[$subindex][1]="";
					} 
				} 
			}
		} 
	}
	return $function_ret;
} 

//滤掉暂时的离线事件: 同一角色在离线事件后的5分钟内如果发现有加入事件则删除这对事件.
function fixOfflineEvents($joinevents,$leaveevents){
	if (!(is_array($joinevents) && is_array($leaveevents))){
		return $function_ret;
	} 
	for ($jindex=0; $jindex<=count($joinevents)-1; $jindex=$jindex+1){
		if ($joinevents[$jindex][0]!=""){
			for ($lindex=0; $lindex<=count($leaveevents)-1; $lindex=$lindex+1){
				if ($leaveevents[$lindex][0]!="" && $joinevents[$jindex][0]!=""){
					if ($joinevents[$jindex][0]==$leaveevents[$lindex][0]){
						if (($DateDiff["n"][$joinevents[$jindex][1]][$leaveevents[$lindex][1]]>-5 && $DateDiff["n"][$joinevents[$jindex][1]][$leaveevents[$lindex][1]]<0)){
							//Or (DateDiff("n",joinevents(jindex,1),leaveevents(lindex,1)) < 5 And DateDiff("n",joinevents(jindex,1),leaveevents(lindex,1)) > 0)
							print $joinevents[$jindex][0]." 离线修正,删除值对: 加入".$joinevents[$jindex][1]." , 离开".$leaveevents[$lindex][1]." , ".$DateDiff["n"][$joinevents[$jindex][1]][$leaveevents[$lindex][1]]."<br>";
							$joinevents[$jindex][0]="";
							$joinevents[$jindex][1]="";
							$leaveevents[$lindex][0]="";
							$leaveevents[$lindex][1]="";
						} 
					} 
				} 
			}
		} 
	}

	return $function_ret;
} 

*/






/*
function ImportPost(){
	processPlayer_RT150();
	processJoinEvents_RT150();
	processLeaveEvents_RT150();
	CTRT_Loot10();
	processBosskillsEvents_RT150();

	//		if DataFormat="MRT207" then
	//			Call processPlayer_RT150()
	//			Call processJoinEvents_RT150()
	//			Call processLeaveEvents_RT150()
	//			Call CTRT_Wipes()
	//			Call CTRT_Loot10()
	//			Call processBosskillsEvents_RT150()
	//		end if
	return ;
}


function ImportMenu(){
  print "<a href='?Action=Form'>数据导入</a>";
  print " | <a href='?Action=Post'>查看分析结果</a>";
  return $function_ret;
} 





$parser = xml_parser_create(); //创建一个parser编辑器
xml_set_element_handler($parser, "startElement", "endElement");//设立标签触发时的相应函数 这里分别为startElement和endElenment
xml_set_character_data_handler($parser, "characterData");//设立数据读取时的相应函数
$xml_file="1.xml";//指定所要读取的xml文件,可以是url
$filehandler = fopen($xml_file, "r");//打开文件




while ($data = fread($filehandler, 4096)) 
{
    xml_parse($parser, $data, feof($filehandler));
}//每次取出4096个字节进行处理

fclose($filehandler);
xml_parser_free($parser);//关闭和释放parser解析器


$name=false;
$position=false;
function startElement($parser_instance, $element_name, $attrs)        //起始标签事件的函数
 {
   global $name,$position;  
   if($element_name=="NAME")
   {
   $name=true;
   $position=false;
   echo "名字:";
  }
  if($element_name=="POSITION")
   {$name=false;
   $position=true;
   echo "职位:";
  }
}

function characterData($parser_instance, $xml_data)                  //读取数据时的函数 
{
   global $name,$position;
   if($position)
    echo $xml_data."<br>";
    if($name)
     echo $xml_data."<br>";
}

function endElement($parser_instance, $element_name)                 //结束标签事件的函数
{
 global $name,$position; 
$name=false;
$position=false;  
}

*/

?>
